import {FormProps, FormSchema} from '/@/components/Table';

import {BasicColumn} from '/@/components/Table/src/types/table';
import {Tag} from "ant-design-vue";
import {h} from 'vue';


//表格显示列
export function getBasicColumns(): BasicColumn[] {
  // @ts-ignore
  return [

    {
      title: '租户名称',
      dataIndex: 'name',
      width: 150,

    },
    {
      title: '租户编号',
      dataIndex: 'code',
      width: 100,
    },
    {
      title: '小程序code',
      dataIndex: 'appletCode',
      width: 100,
    },
    {
      title: '开始时间',
      dataIndex: 'startTime',
      width: 150,
    },
    {
      title: '结束时间',
      dataIndex: 'endTime',
      width: 150,
    },
    {
      title: '状态',
      width: 100,
      dataIndex: 'status',
      customRender: ({record}) => {
        let status = record.status;
        let color = ''
        switch (status) {
          case '0':
            status = '正常';
            color = 'green'
            break;
          case '9':
            status = '冻结';
            color = 'purple'
            break;
        }
        return h(Tag, {color: color}, () => status);
      },
    },

  ];
}

export function getFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 150,
    baseColProps: {lg: 6, md: 24},
    schemas: formParamSchema,
  };
}


//查询条件表单
export const formParamSchema: FormSchema[] = [
  {
    field: 'name',
    label: '租户名称',
    component: 'Input',
  },

];

//编辑表单
export const formSchema: FormSchema[] = [
  {
    field: 'name',
    label: '租户名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'code',
    label: '租户编号',
    component: 'Input',
    required: true,
  },
  {
    field: 'appletCode',
    label: '小程序code',
    component: 'Input',
    required: true,
  },
  {
    field: 'startTime',
    label: '开始时间',
    component: 'DatePicker',
    required: true,
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endTime',
    label: '结束时间',
    component: 'DatePicker',
    required: true,
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },

  {
    field: 'status',
    label: '状态',
    component: 'RadioButtonGroup',
    defaultValue: '0',
    required: true,
    componentProps: {
      options: [
        {label: '正常', value: '0'},
        {label: '冻结', value: '9'},
      ],
    },
  },

];
